package com.example.tracontroller;

import java.io.IOException;

import android.content.Context;
import android.location.Location;
import android.media.ExifInterface;
import android.widget.Toast;
public class AddGPSInfo {
	public static void addImage(Location location, String _filePath) {

        String filePath = _filePath;

        if (location != null) {

           ExifInterface exif = null;

        try {

            exif = new ExifInterface(filePath);

        } catch (IOException ex) {

          
           }

         exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE, Double.toString(location.getLatitude()));        
         
           exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE, Double.toString(location.getLongitude()));

           try{

               if(exif != null)

              exif.saveAttributes();

           } catch (IOException ex) {
           }

       }
	}
	public static void readImage(Context _context ,String _filePath){
		
		String filePath = _filePath;
		try{
			ExifInterface exif = new ExifInterface(filePath);
			String sModel=exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE);
			Toast.makeText(_context,"1.JPG Exif:"+sModel, Toast.LENGTH_SHORT).show();
			}
			catch(Exception ee){

			} 
		
	}
   

}

 
